package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.HaDrugAccept;
import com.ruoyi.system.service.IHaDrugAcceptService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 收货质检Controller
 * 
 * @author 报销为
 * @date 2025-11-26
 */
@RestController
@RequestMapping("/system/accept")
public class HaDrugAcceptController extends BaseController
{
    @Autowired
    private IHaDrugAcceptService haDrugAcceptService;

    /**
     * 查询收货质检列表
     */
    @PreAuthorize("@ss.hasPermi('system:accept:list')")
    @GetMapping("/list")
    public TableDataInfo list(HaDrugAccept haDrugAccept)
    {
        startPage();
        List<HaDrugAccept> list = haDrugAcceptService.selectHaDrugAcceptList(haDrugAccept);
        return getDataTable(list);
    }

    /**
     * 导出收货质检列表
     */
    @PreAuthorize("@ss.hasPermi('system:accept:export')")
    @Log(title = "收货质检", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HaDrugAccept haDrugAccept)
    {
        List<HaDrugAccept> list = haDrugAcceptService.selectHaDrugAcceptList(haDrugAccept);
        ExcelUtil<HaDrugAccept> util = new ExcelUtil<HaDrugAccept>(HaDrugAccept.class);
        util.exportExcel(response, list, "收货质检数据");
    }

    /**
     * 获取收货质检详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:accept:query')")
    @GetMapping(value = "/{acceptid}")
    public AjaxResult getInfo(@PathVariable("acceptid") Long acceptid)
    {
        return success(haDrugAcceptService.selectHaDrugAcceptByAcceptid(acceptid));
    }

    /**
     * 新增收货质检
     */
    @PreAuthorize("@ss.hasPermi('system:accept:add')")
    @Log(title = "收货质检", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HaDrugAccept haDrugAccept)
    {
        return toAjax(haDrugAcceptService.insertHaDrugAccept(haDrugAccept));
    }

    /**
     * 修改收货质检
     */
    @PreAuthorize("@ss.hasPermi('system:accept:edit')")
    @Log(title = "收货质检", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HaDrugAccept haDrugAccept)
    {
        return toAjax(haDrugAcceptService.updateHaDrugAccept(haDrugAccept));
    }

    /**
     * 删除收货质检
     */
    @PreAuthorize("@ss.hasPermi('system:accept:remove')")
    @Log(title = "收货质检", businessType = BusinessType.DELETE)
	@DeleteMapping("/{acceptids}")
    public AjaxResult remove(@PathVariable Long[] acceptids)
    {
        return toAjax(haDrugAcceptService.deleteHaDrugAcceptByAcceptids(acceptids));
    }
}
